<%@ page import="java.util.List" %>
<%@ page import="com.xueqi.bean.EbookEntry" %>
<%@ page import="com.xueqi.bean.EbookCategory" %>
<%@ page import="com.xueqi.utils.PageUtils" %><%--
  Created by IntelliJ IDEA.
  User: pc
  Date: 2019/10/26
  Time: 20:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
<script type="text/javascript">
    function goto() {
        location.href="/entry?method=gettypes";//获得类型列表的请求
    }
</script>
</head>
<body>
<%
    PageUtils<EbookEntry> p1 = (PageUtils<EbookEntry>) request.getAttribute("p1");
    List<EbookCategory> typelist=(List<EbookCategory>)request.getAttribute("typelist");
%>
<p>
    <form action="/entry" method="post">
    <input type="hidden" name="method" value="selectall">
    图书分类:<select name="typeid">
    <option value="0">全部</option>
    <%
        int categorytid = (int)request.getAttribute("categorytid");
        for (EbookCategory category:typelist){
    %>

    <option value="<%=category.getId()%>" <%if(category.getId()==categorytid){%>selected<%}%>><%=category.getName()%></option>
    <%}%>
</select>
    <input type="submit" value="查询">
    </form></p>
<p><input type="button" value="新增电子书" onclick="goto()"></p>
<table border="1" cellspacing="0" width="70%">
    <tr>
        <td>编号</td>
        <td>名称</td>
        <td>类型</td>
        <td>摘要</td>
        <td>日期</td>
        <td>上传人</td>
        <td>操作</td>
    </tr>
    <% for (EbookEntry entry:p1.getDataList()){%><tr>
    <td><%=entry.getId()%></td>
    <td><%=entry.getTitle()%></td>
    <td><%=entry.getType().getName()%></td>
    <td><%=entry.getSummary()%></td>
    <td><%=entry.getCreatedate()%></td>
    <td><%=entry.getUploaduser()%></td>
    <td><a href="/entry?method=delete&tid=<%=entry.getId()%>">删除</a>
        <a href="/entry?method=findbyid&tid=<%=entry.getId()%>">修改</a></td>
    </tr>
<% }%>
    <tr>

        <td colspan="7" align="right">
            <a href="/entry?method=selectall&index=1&typeid=<%=categorytid%>">首页</a>
            <a href="/entry?method=selectall&index=<%=p1.getPageIndex()==1?1:p1.getPageIndex()-1%>&typeid=<%=categorytid%>">上一页</a>
            <%for (int i=1;i<=p1.getTotalPages();i++){%>
            <%if(i==p1.getPageIndex()){%>
                    <a href="entry?method=selectall&index=<%=i%>&typeid=<%=categorytid%>"><%=i%></a>
            <%}else{%>
            <a href="entry?method=selectall&index=<%=i%>&typeid=<%=categorytid%>" style="text-decoration: none"><%=i%></a>
            <%}%>
            <%}%>
            <a href="entry?method=selectall&index=<%=p1.getPageIndex()==p1.getTotalPages()?p1.getTotalPages():p1.getPageIndex()+1%>&typeid=<%=categorytid%>">下一页</a>
            <a href="entry?method=selectall&index=<%=p1.getTotalPages()%>&typeid=<%=categorytid%>">尾页</a>
            第<%=p1.getPageIndex()%>页/共<%=p1.getTotalPages()%>页 共<%=p1.getTotalCount()%>条
        </td>
    </tr>
</table>
</body>
</html>
